﻿@model Models.Car_carInfo

<!DOCTYPE html>

<html>
<head>
    <title>添加用户信息</title>
    <link href="../../Content/tableStyle.css" rel="stylesheet" />
    @Scripts.Render("~/mvcAjax")
    @*实现异步上传图片的功能*@
    <script src="../../Scripts/MyAjaxForm.js"></script>

    @*引入富文本编辑器的使用*@
    <script src="../../kindeditor-4.1.3/kindeditor.js"></script>
    <script src="../../kindeditor-4.1.3/lang/zh_CN.js"></script>
    <script src="../../kindeditor-4.1.3/plugins/code/prettify.js"></script>
    <script type="text/javascript">
        @*父文本框的使用*@
        KindEditor.ready(function (K) {
            //实现显示富文本的代码，第一个方法,实现添加的框架
            window.editorAdd = K.create('#content', {
                cssPath: '../../kindeditor-4.1.3/plugins/code/prettify.css',
                uploadJson: 'upload_json.ashx',
                fileManagerJson: 'file_manager_json.ashx',
                allowFileManager: true,
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {//添加保存信息的组合键ctrl+z
                        self.sync();//同步富文本编辑器里的内容到textarea中去
                        K('form[name="AddNewsContent"]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name="AddNewsContent"]')[0].submit();
                    });
                }
            });
            //不知道什么用处，暂时添加在这里
            prettyPrint();

            //获取添加文本框内容
            function getEditorAddData() {
                return editorAdd.html();     //使用上面定义的window.editorAdd的方法的HTML代码
            }

            //实现操作Jquery的方法
            $(function () {


                //定义参数保存路径
                var imgFileName;
                //实现异步上传图片
                $("#btnFileImg").click(function () {
                    $("#frmUploadImg").ajaxSubmit({
                        URL: "/MainDetail/FileUpload",
                        type: "post",
                        success: function (imgFileData) {
                            var arr = imgFileData.split("|")
                            if (arr[0]=="ok") {
                                $("#result").append("<img width='150' height='130' src='../../upImg/" + arr[1] + "'>");
                                imgFileName = arr[1];
                            }
                            else {
                                alert(arr[1]);
                            }

                        }
                    });
                });

                //实现添加新闻的信息
                $("#btnAddMain").click(function () {
                    //txtMainTitle，content，txtMainDateTime，txtMainPeople，txtMainPic
                    //获得要传递的参数
                    var MainData = {
                        title: $("#title").val(),
                        content: getEditorAddData(),
                        newsSource: $("#newsSource").val(),
                        newsTypeid: $("#newsTypeid").val(),
                        newsImage: imgFileName
                    };
                    $.ajax({
                        url: "/News/SaveNews",
                        data:MainData,
                        type: "post",
                        success: function (data) {
                            if (data.Status == "ok") {
                                alert("添加成功，正在跳转中");
                                window.location.href = "../news/newsview";
                            }
                            else {
                                alert("添加失败，请您检查");
                            }
                        }
                    });
                });
            });
        });


    </script>
</head>
<body>
    <form id="frmUploadImg" enctype="multipart/form-data" action="/news/FileUpload">
        <div>
            <table style="font-size:14px;">
                <tr>
                    <th colspan="2">添加新闻列表信息</th>
                </tr>
                <tr>
                    <td>上户年：：</td>
                    <td>
                        <input class="easyui-numberbox" type="text" id="Years" name="Years" />
                    </td>
                </tr>
                <tr>
                    <td>品牌：：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="BrandName" name="BrandName" />
                    </td>
                </tr>
                <tr>
                    <td>型号：：：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="XingHao" name="XingHao" />
                    </td>
                </tr>
                <tr>
                    <td>排量：：</td>
                    <td>
                        <input class="easyui-numberbox" type="text" id="EngineCC" name="EngineCC" />
                    </td>
                </tr>
                <tr>
                    <td>涡轮增压：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="HasT" name="HasT" />
                </tr>
                <tr>
                    <td>变速箱：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="HasT" name="HasT" />
                </tr>
                <tr>
                    <td>交强险到期：：</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="JQXDaoQi" name="JQXDaoQi" />
                </tr>
                <tr>
                    <td>商业险到期：：</td>
                    <td>
                        <input class="easyui-datebox" type="text" id="SYxDaoQi" name="SYxDaoQi" />
                </tr>
                <tr>
                    <td>成本价：：</td>
                    <td>
                        <input class="easyui-numberbox" type="text" id="CostPrice" name="CostPrice" />
                </tr>
                <tr>
                    <td> 显示价：：</td>
                    <td>
                        <input class="easyui-numberbox" type="text" id="ShowPrice" name="ShowPrice" />
                </tr>
                <tr>
                    <td>可卖最低价：：</td>
                    <td>

                        <input class="easyui-numberbox" type="text" id="SellPrice" name="SellPrice" />
                </tr>
                <tr>
                    <td>成交价：</td>
                    <td>
                        <input class="easyui-numberbox" type="text" id="ClosePrice" name="ClosePrice" />
                </tr>
                <tr>
                    <td>显示文：：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="ShowTxt" name="ShowTxt" />
                </tr>
                <tr>
                    <td>隐藏文：：</td>
                    <td>
                        <input class="easyui-validatebox" type="text" id="HideTxt" name="HideTxt" />
                </tr>

                <tr>
                    <td>图片：</td>
                    <td>
                        <input type="file" name="txtMainPic" id="txtMainPic" />
                        <input type="button" name="btnFileImg" id="btnFileImg" value="上传" />

                    </td>
                </tr>
                <tr>
                    <td>图片显示：</td>
                    <td><div id="result"></div></td>
                </tr>
                <tr>

                    <td colspan="2" align="center">
                        <input type="button" name="btnAddMain" value="添加" id="btnAddMain" />&nbsp;&nbsp;&nbsp;
                        <input type="button" value="返回" id="back" onclick="window.location='../news/newsview'" />
                    </td>

                </tr>
            </table>
        </div>
    </form>
</body>
</html>
